package com.tarena.lbs.content.dao.repository.impl;

import com.tarena.lbs.content.dao.mapper.CategoryMapper;
import com.tarena.lbs.content.dao.repository.CategoryRepository;
import com.tarena.lbs.content.pojo.param.ArticleCategoryParam;
import com.tarena.lbs.content.pojo.vo.ArticleCategoryVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class CategoryRepositoryImpl implements CategoryRepository {
    @Autowired
    private CategoryMapper categoryMapper;

    /*
    * 新增分类
    * */
    @Override
    public void addCategory(ArticleCategoryParam param) {
        log.debug("新增分类参数：{}",param);
        categoryMapper.addCategory(param);
    }

    /*
    * 查询分类数量
    * */
    @Override
    public Long selectCategoryCount(String categoryName,Integer categoryStatus) {
        Long total = categoryMapper.selectCategoryCount(categoryName,categoryStatus);
        log.debug("分类数量：{}",total);
        return total;
    }

    @Override
    public List<ArticleCategoryVO> selectCategory(String categoryName,Integer categoryStatus) {
        List<ArticleCategoryVO> categoryList = categoryMapper.selectCategory(categoryName,categoryStatus);
        log.debug("分类列表：{}",categoryList);
        return categoryList;
    }

    @Override
    public int updateCategory(ArticleCategoryParam articleCategoryParam) {
        log.debug("修改分类参数：{}",articleCategoryParam);
        int num = categoryMapper.updateCategory(articleCategoryParam);
        return num;
    }
}
